<!DOCTYPE html>
<html>
<head>
<head/>
<div th:include="base-libs :: base-libs" />
<title>医疗机构人员</title>
<style type="text/css">

</style>
</head>
<script type="text/javascript">
 $(function() {
 	initView();
});

function queryForm() {
	$("#yljgryTable").datagrid("reload");
}

function initView()
{
	/**加载值域*/
	initDatagrid();
	/**确认按钮*/
	$("#enter").on("click", function(){
		var rows = $("#yljgryTable").datagrid("getSelections");
		if(validateYljgry(rows)){
			/**查询医联体所有信息*/
			var xm = "";
			var userid = "";
			$(rows).each(function(index, item){
				xm += item["XM"]+",";
				userid += item["USERID"]+",";
			});
			StoreCache.setCache("LSHGL_YLJGRYXX",{
				XM: xm.substring(0, xm.length-1),
				USERID: userid.substring(0, userid.length-1)
			});
			parent.layer.closeAll("iframe");
		}
	});
	/**关闭按钮*/
	$("#close").on("click", function(){
		parent.layer.closeAll("iframe");
	});
}

function initDatagrid(){
	var cache = StoreCache.removeCache("LSHGL_YLJGRYXX");
	var status = false;
	if(cache["LX"]=="lsz"){
		status = true;
	}
	var opt = {
				idField : "USERID",
				uniqueId : "USERID",
				striped : true,
				columns : [ [ 
				{
					field: "checkStatus",
					checkbox: true
				},{
					field : "XM",
					width : 150,
					align : "center",
					title : "姓名"
				}, {
					field : "SJHM",
					width : 150,
					align : "center",
					title : "手机号码"
				}, {
					field : "XBMC",
					width : 150,
					align : "center",
					title : "性别"
				}, {
					field : "YLJGMC",
					width : 250,
					align : "center",
					title : "所属医疗机构"
				}, {
					field : "ZCMC",
					width : 150,
					align : "center",
					title : "职称"
				}] ],
				pagination : true,
				pageNumber : 1,
				pageSize : 10,
				fit : true,
				fitColumns : true,
				singleSelect : status,
				rownumbers : true,
				method : "post",
				url : "queryYljgrylb.service",
				onBeforeLoad : function(params)//加载之前回调 获取查询条件
				{
					params["XM"] = $("#XM").val();
					params["YLJGMC"] = $("#YLJGMC").val();
					return params;
				},onLoadSuccess: function(data){ 
					if(cache["LX"]=="lsz"){
						$("#yljgryTable").datagrid("hideColumn","checkStatus");
					}
					/**选中已选行*/
					var userid = cache["USERID"];
					if(!StringUtils.isEmpty(userid)){
						var ids = userid.split(",");
						$(ids).each(function(index, item){
							$("#yljgryTable").datagrid("selectRecord",item);
						});
					}
				}
			};
	/**加载机构*/
	$("#yljgryTable").datagrid(opt);
}

/**查询按钮*/
function btnQueryHandler(){
	queryDatagrid();
}

/**刷新datagrid*/
function queryDatagrid(){
	$("#yljgryTable").datagrid("reload");
}

/**校验是否选择医联体*/
function validateYljgry(rows){
	var flag = false;
	if(rows.length == 0){
		$.QuickAlert.alertFail({
			content : "请选择医疗机构人员！",
		});
	}else{
		flag = true;
	}
	return flag 
}
</script>

<body>
<div class="easyui-layout" fit="true" style="width: 100%;">
	<!-- <div region="north" style="border: none; overflow: hidden;">
	<h4 class="h4-title" style="font-size: 18px;">
		医联体信息列表
	</h4>
	</div> -->
	<div region="center" style="border: none;overflow: hidden;">
	<div class="easyui-layout" style="width:100%;border: none;height: 400px;" fit="true" id='dataGridDiv'>
		<div region="north" style="border: none;overflow: hidden;">
			<div id="dgFormToolbar" style="background: white;">
				<table class="form-table" style="">
					<tr>
						<td class="td-text">姓名：</td>
						<td class="td-content">
							<input id="XM" type="text" placeholder="姓名">
						</td>
						<td class="td-text">所属医疗机构：</td>
						<td>
							<input id="YLJGMC" type="text" placeholder="所属医疗机构">
						</td>
						<td class="td-text">
							<button class="btn btn-default" type="button"
							onclick="btnQueryHandler()">查询</button>
						</td>
					</tr>
				</table>
			</div>
		</div>
		<div region="center" style="border: none;height: 300px">
			<table id="yljgryTable">
			</table> 
		</div>
	</div>
	</div>
	<div region="south" style="border: none;">
		<div style="float:right;height: 30px;margin-right: 10px;">
			<button type="button" id="enter">确认</button>
			&nbsp;
			<button type="button" id="close">关闭</button>
		</div>
	</div>
</div>
</body>
</html>



